﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WindowDialog.xaml.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Interaction logic for WindowDialog.xaml
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Windows.Client.View
{
    using System;
    using System.Windows;
    using Common;

    /// <summary>
    /// Interaction logic for WindowDialog.xaml
    /// </summary>
    public partial class WindowDialog
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowDialog"/> class.
        /// </summary>
        public WindowDialog()
        {
            InitializeComponent();
            DialogPresenter.DataContextChanged += DialogPresenterDataContextChanged;
        }

        /// <summary>
        /// Dialogs the presenter data context changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private void DialogPresenterDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var d = e.NewValue as IDialogResultHelper;
            if (d == null)
            {
                return;
            }

            d.DialogResultTrueEvent += DialogResultTrueEvent;
        }

        /// <summary>
        /// Dialogs the result true event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void DialogResultTrueEvent(object sender, EventArgs e)
        {
            DialogResult = true;
        }
    }
}